% Esercizio 1
close all
clear all
clc

format long e

xv = pi;
xappr = 3.1415926;

err.ass = abs(xv-xappr);
err.rel = abs(xv-xappr)/abs(xv);
cf = -log10(err.rel);

p1 = [xv, xappr, err.ass, err.rel, cf]


xv = exp(1);
xappr = 2.71;

err.ass = abs(xv-xappr);
err.rel = abs(xv-xappr)/abs(xv);
cf = -log10(err.rel);

p2 = [xv, xappr, err.ass, err.rel, cf]


xv = 0.123456789e-20;
xappr = 0.12e-20;

err.ass = abs(xv-xappr);
err.rel = abs(xv-xappr)/abs(xv);
cf = -log10(err.rel);

p3 = [xv, xappr, err.ass, err.rel, cf]


xv = 0.123456789e+20;
xappr = 0.12e+20;

err_ass = abs(xv-xappr);
err_rel = abs(xv-xappr)/abs(xv);
cf = -log10(err_rel);

p4 = [xv, xappr, err_ass, err_rel, cf]

format long e;

risultati = [p1,p2,p3,p4];

